/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ziad;

import SessionFactory.SessionFactoryUtil;
import dto.Posts;
import dto.Topics;
import dto.TopicsHome;
import java.util.Iterator;
import java.util.Set;
import org.hibernate.SessionFactory;





/**
 *
 * @author ZiZo
 */
public class Test {
    TopicsHome tHome = new TopicsHome();
    public static void main(String args[]){
        new Test();
    }
    Topics topics;
    public Test(){
//        SessionFactory sessionFactory = SessionFactoryUtil.getInstance();
//        sessionFactory.getCurrentSession().beginTransaction();
        SessionFactoryUtil.startNew();
        topics = tHome.findById(new Integer(1));
        System.out.println("" + topics.getTopicname());
        Set<Posts> postsS = topics.getPostses();
        Iterator<Posts> postsI = postsS.iterator();
        while(postsI.hasNext()){
            System.out.println(""+postsI.next().getContent());
        }
//        sessionFactory.getCurrentSession().close();
        SessionFactoryUtil.finish();
    }
    public Topics getTopics(){
        return topics;
    }

}
